﻿@model Proggy.Web.Cms.Core.PropertyTypes.ProggyImagePicker
@{
    //Html.RenderAction("RenderImage", new { controller = "ProggyImagePicker", area = "ProggyCore", model=Model });    


    // vars
    var src = string.Empty;
    var altTag = string.Empty;
    var height = string.Empty;
    var width = string.Empty;

    if (Model.IsExternalImage)
    {
        src = Model.ExternalUrl;
        altTag = Model.ExternalAltTag;
    }
    else
    {
        if (Model.InternalNodeId != null)
        {
            // get url
            var url = Proggy.Web.Cms.Cache.UrlCache.GetUrlFromNodeId((int)Model.InternalNodeId);

            // set
            src = url;
            altTag = Model.InternalAltTag;
        }
    }
    
    // check height
    if(Model.Height !=null){
        height = "height=" + Model.Height+ " ";
    }
    
    // check width
    if(Model.Width != null){
        width = "width=" + Model.Width;
    }

    // render
    <img src="@src" alt="@altTag" @(width) @(height) />
}
